package com.example.demosdk;

import com.example.myDll.InfraDataCallBackDll;
import com.example.myDll.MyDllCallBack;
import com.example.myImpl.InfraDataCallBackImpl;
import com.example.myImpl.MyDllCallbackImpl;
import com.sun.jna.platform.win32.WinDef;
import com.sun.jna.*;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;


public class getTemperMain {

    static DLSDK dlSdk = null;
    static DLFrameSDK dlFrameSDK = null;
    public static synchronized void loadDlLibrary(String libraryPath){
        if (null == dlSdk){
            dlSdk = (DLSDK) Native.loadLibrary(libraryPath,DLSDK.class);
        }
    }
    public static synchronized void loadDlFrameLibrary(String libraryPath){
        if (null == dlFrameSDK){
            dlFrameSDK = (DLFrameSDK) Native.loadLibrary(libraryPath,DLFrameSDK.class);
        }
    }

    public static void main(String args[]) throws Exception{
        loadDlLibrary("static/DLSDK/DMSDK");
        loadDlFrameLibrary("static/Demo/InfraredSDK");
        WinDef.HWND myHwnd = new WinDef.HWND();
        String cameraIp = "192.168.1.21";
//        String savePath = "E:\\项目\\demoSdk\\src\\main\\resources\\static\\DLMemory";
        dlSdk.DM_Init();
        int connectHandle = dlSdk.DM_Connect(myHwnd,cameraIp,8000);
        if(connectHandle>0){System.out.println("连接成功");}

        /**
         * 这部分是DM中设置区域的温度
         */
        int setAreaResult =  dlSdk.DM_SetArea(connectHandle,1,30,30,60,60,10,2);
        if(setAreaResult>0){System.out.println("设置区域成功");}
        int getAreaResult =  dlSdk.DM_GetAreaTemp(connectHandle,1, 0);
        if(getAreaResult>0){System.out.println("获得区域温度成功");}
        MyDllCallBack callback = new MyDllCallbackImpl();
        long exHandle = dlSdk.DM_RecvInfraredData_EX(connectHandle,0,20,callback);
        Thread.sleep(5000);
        System.out.println("ex函数的返回结果"+exHandle);

        dlSdk.DM_Disconnect(myHwnd);

    }


}
